﻿#include "SingleLinkedListWithHead.h"

// 头部操作测试
void test1()
{
	ListNode* list = NULL;
	SingleHeadListInit(&list);
	SingleHeadListPushFront(list, 1);
	SingleHeadListPushFront(list, 2);
	SingleHeadListPushFront(list, 3);
	SingleHeadListPushFront(list, 3);
	SingleHeadListPushFront(list, 3);
	SingleHeadListTraverse(list);

	SingleHeadListPopFront(list);
	SingleHeadListPopFront(list);
	SingleHeadListTraverse(list);

	SingleHeadListPopFront(list);
	SingleHeadListTraverse(list);
}

// 尾部操作测试
void test2()
{
	ListNode* list = NULL;
	SingleHeadListInit(&list);
	SingleHeadListPushBack(list, 1);
	SingleHeadListPushBack(list, 2);
	SingleHeadListPushBack(list, 3);
	SingleHeadListPushBack(list, 4);
	SingleHeadListPushBack(list, 5);
	SingleHeadListTraverse(list);

	SingleHeadListPopBack(list);
	SingleHeadListPopBack(list);
	SingleHeadListPopBack(list);
	SingleHeadListTraverse(list);

	SingleHeadListPopBack(list);
	SingleHeadListPopBack(list);
	SingleHeadListTraverse(list);
}

// 中部操作测试
void test3()
{
	ListNode* list = NULL;
	SingleHeadListInit(&list);
	SingleHeadListPushBack(list, 1);

	SingleHeadListInsertAfter(list, 0, 4);
	SingleHeadListInsertAfter(list, 0, 3);
	SingleHeadListInsertAfter(list, 0, 2);
	SingleHeadListTraverse(list);

	SingleHeadListInsertAfter(list, 3, 666);
	SingleHeadListTraverse(list);

	SingleHeadListEraseAfter(list, 3);
	SingleHeadListEraseAfter(list, 0);
	SingleHeadListEraseAfter(list, 1);
	SingleHeadListTraverse(list);
}

int main()
{
	test3();
	return 0;
}